package cn.bonoon.kernel.web.components;

import cn.bonoon.kernel.descriptors.UIPropertyAccessor;
import cn.bonoon.kernel.web.annotations.components.AsTextArea;
import cn.bonoon.kernel.web.html.UIPropertyBuilder;
import cn.bonoon.kernel.web.html.form.ComponentPropertyParser;

public class TextAreaComponent extends AbstractComponent {
	private final AsTextArea com;

	public TextAreaComponent(ComponentPropertyParser property, UIPropertyAccessor accessor, AsTextArea asTextArea) {
		super(property, accessor);
		this.com = asTextArea;
	}

	@Override
	protected void parser(UIPropertyBuilder builder) {
		int width = componentWidth();
		StringBuilder html = builder.getInitHtml();
		html.append("<textarea");
		__component(html);
		html.append("style='width:").append(width).append("px;");
		int r = com.rows();
		if (r > 0) {
			html.append("' rows='").append(r);
		}
		String bindedName = builder.getBindedName();
		html.append("'>$!{").append(bindedName).append('.').append(componentName).append("}</textarea>");
	}
}
